package locksupport.park;

import java.util.concurrent.locks.LockSupport;

/**
 * @author ZhuQi
 * @ClassName LockSupportDemo
 * @Date 2022/9/13 15:21
 * @Version 1.0
 * @Description 测试 LockSupport 的 park 和 unPark
 */
public class LockSupportDemo {
    public static void main(String[] args) {
        Thread thread1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " park");
            LockSupport.park();
            System.out.println(Thread.currentThread().getName() + " 唤醒");

        }, "thread1");

        Thread thread2 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " unpark");
            LockSupport.unpark(thread1);
        }, "thread2");

        thread1.start();
        thread2.start();
    }


}
